import uuid

from django.db import models
from User.models import *


# Create your models here.
class GroupInfo(models.Model):
    GroupID = models.UUIDField(verbose_name='团队ID', unique=True, db_index=True, primary_key=True, default=uuid.uuid1, editable=False)
    GroupName = models.CharField(verbose_name='团队名', max_length=128)
    Introduction = models.TextField(default='队长较懒，没有写简介~', verbose_name='简介')
    create_date = models.DateTimeField(verbose_name='时间', auto_now=True)

    class Meta:
        verbose_name = "团队信息"
        verbose_name_plural = verbose_name+"管理"

    def __str__(self):
        return self.GroupName


class GroupMember(models.Model):
    StudentID = models.OneToOneField(UserInfo, verbose_name='学号', db_index=True, on_delete=models.CASCADE)
    GroupID = models.ForeignKey(GroupInfo, verbose_name='团队ID', db_index=True, on_delete=models.CASCADE)
    Auth_choices = (
        (0, '创建者'),
        (1, '管理员'),
        (2, '成员')
    )
    Auth = models.IntegerField(verbose_name='权限', choices=Auth_choices)

    class Meta:
        verbose_name = "团队成员"
        verbose_name_plural = verbose_name+"管理"
        unique_together = ("StudentID", "GroupID")

